namespace SimpleWebServices.Web
{
    using System.Web;
    using Moq;

    public static class HttpContextBaseMock
    {
        public static HttpContextBase New()
        {
            var context = new Mock<HttpContextBase>();
            var request = new Mock<HttpRequestBase>();
            var response = new Mock<HttpResponseBase>();
            var session = new Mock<HttpSessionStateBase>();
            var server = new Mock<HttpServerUtilityBase>();

            context.Setup(x => x.Request).Returns(request.Object);
            context.Setup(x => x.Response).Returns(response.Object);
            context.Setup(x => x.Session).Returns(session.Object);
            context.Setup(x => x.Server).Returns(server.Object);

            return context.Object;
        }

        public static HttpContextBase New(string method, string path)
        {
            var context = New();
            context.Request.SetHttpMethod(method);
            context.Request.SetHttpRequestUrl(path);

            return context;
        }
    }
}